<?=$this->header()?>


    <?=$this->menu("contacts")?>


    <h1><?=$this->message("label.header", _Contact::BUNDLE)?></h1>


    <? /* Breadcrums route & contact info display */ ?>
    <?=$this->route(
        $this->message("label.header", _Contact::BUNDLE),   // Route display
        $this->contactListForm,                             // ListForm (for contact info, see float right)
        $this->contacts($this->contactListForm)->getRows()) // The total amount of contacts
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->contactListForm)?>"
          method="post"
          action="contact/index"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "contact/edit",         // Add New URL
            $this->contactListForm, // ListForm
            array(                // Filter fields
                ContactPeer::FIRSTNAME=>$this->message("prompt.firstname", _Contact::BUNDLE),
                ContactPeer::SURNAME=>$this->message("prompt.surname", _Contact::BUNDLE),
                ContactPeer::EMAIL=>$this->message("prompt.email", _Contact::BUNDLE),
                ContactPeer::PHONE=>$this->message("prompt.phone", _Contact::BUNDLE),
                ContactPeer::OFFICE=>$this->message("prompt.office", _Contact::BUNDLE),
                ContactPeer::ROLE=>$this->message("prompt.function", _Contact::BUNDLE),
                ContactPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                ContactPeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE),
                ContactPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE),
            ),
            false // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th class="narrow"></th>
            <th>
                <?=$this->TH(
                    $this->contactListForm,                     // ListForm
                    ContactPeer::SURNAME,                        // Sort Field
                    $this->message("prompt.surname", _Contact::BUNDLE) // Header Name
                )?>
            </th>
            <th>
                <?=$this->TH(
                    $this->contactListForm,                       // ListForm
                    ContactPeer::FIRSTNAME,                        // Sort Field
                    $this->message("prompt.firstname", _Contact::BUNDLE) // Header Name
                )?>
            </th>
            <th>
                <?=$this->TH(
                    $this->contactListForm,                          // ListForm
                    ContactPeer::EMAIL,                              // Sort Field
                    $this->message("prompt.email", _Contact::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->contactListForm,             // ListForm
                    ContactPeer::MODIFIED_DATE,          // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->contactListForm,            // ListForm
                    ContactPeer::INSERT_DATE,           // Sort Field
                    $this->message("choose.created", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->contactListForm,          // ListForm
                    ContactPeer::ACTIVE,              // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->contacts($this->contactListForm)->getItems() as $contact) { ?>

            <? /* Display the default language contact */ ?>
            <tr class="ctrl">
                <td class="checkbox">
                    <input type="checkbox"
                           name="items[]"
                           value="<?=$contact->getContactId()?>"
                           <?=in_array($contact->getContactId(), $this->contactListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td>
                    <? if($contact->getImageId() > 0): ?>
                    <a title="<?=$this->message("title.image", _Core::BUNDLE)?>" href="image?id=<?=$contact->getImageId()?>">
                        <?=$this->thumbnail($contact->getThumbnailId())?>
                    </a>
                    <? endif; ?>
                </td>
                <td><?=$contact->getSurname()?></td>
                <td><?=$contact->getFirstname()?></td>
                <td title="<?=$this->message("label.email", _Contact::BUNDLE)?>">
                    <a href="mailto:<?=$contact->getEmail()?>">
                        <?=$this->truncateNicely($contact->getEmail(), 10, 16, "...")?>
                    </a>
                </td>
                <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$contact->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$contact->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$contact->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$contact->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($contact->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('contact/edit?contact->contactId=<?=$contact->getContactId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$contact->getContactId()?>, '<?=get_class($this->contactListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->contactListForm, // ListForm
            array(                  // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->contactListForm,                            // ListForm
            $this->path()."contact/edit",                      // Add New URL
            $this->contacts($this->contactListForm)->getRows() // The total amount of contacts
        )?>


    </form>

<?=$this->footer()?>